using System;
using NBusiness.Data;
using System.Data.Common;

namespace Example.Business
{
    /// <summary>
    /// Summary description for Class1
    /// </summary>
    public partial class Company
    {
        protected void Log(object sender, InsertEventArgs e)
        {
            LogLevel info = null;
            foreach (LogLevel level in CachedLogLevelCollection.FetchAll())
            {
                if (level.Level == "INFO")
                {
                    info = level;
                    break;
                }
            }

            Company c = sender as Company;

            Example.Business.Log l = Example.Business.Log.CreateNew();
            l.LogLevel = info;
            l.Message = "Company: " + c.Name + " inserted...";
            l.Save();
        }
    }
}